<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title><%= title %></title>
    <link rel="stylesheet" href="stylesheets/bootstrap.min.css" media="screen">
    <style type="text/css">
        .m15{ margin: 15px;}
        .tc{ text-align: center;font-size: 18px;font-weight: 600;}
    </style>
</head>
<body screen_capture_injected="true">
<div class="container">
    <%- message %>
    <form class="col-sm-offset-4 col-sm-4 form-horizontal" role="form" method="post" onsubmit="return false">
        <fieldset>
            <legend></legend>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <p class="tc">登录页面</p>
                </div>
                <div class="panel-body m15">
                    <div class="form-group">
                        <div class="input-group">
                        <span class="input-group-addon">
                        <span class="glyphicon glyphicon-user"></span>
                        </span>
                            <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                        <span class="input-group-addon">
                        <span class="glyphicon glyphicon-lock"></span>
                        </span>
                            <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary btn-block" id="login0">登录</button>
                    </div>
                    <div class="form-group">
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>

<script type="text/javascript" src="javascripts/jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(function(){
        $("#register0").click(function(){
            location.href = 'register';
        });
        $("#login0").click(function(){
            var username = $("#username").val();
            var password = $("#password").val();
            var data = {"username":username,"password":password};
            $.ajax({
                url:'/check',
                type:'post',
                data: data,
                success: function(data,status){
                        if(status == 'success'){
                            location.href = '/index';

                        }
                },
                error: function(data,status){
                    if(status == 'error'){
                        location.href = '/';
                    }
                }
            });
        });
    });
</script>
</body>
</head>
</html>